<?php
namespace Application\Repository;
use Doctrine\ORM\EntityRepository;

class ProvinceRepository extends AbstractRepository
{
    protected  $entity="Application\\Entity\\Province";
    
    public function getByCountry($code)
    {
        $dql = "SELECT c FROM $this->entity c WHERE c.country.code=?1";

        return $this->getEntityManager()->createQuery($dql)
                             ->setParameter(1, $code)
                             ->getResult();
    }
    
    public function getByNameCountry($name,$code)
    {
    	$dql = "SELECT c FROM $this->entity c WHERE c.name=?1 AND c.country.code=?2";
    
    	return $this->getEntityManager()->createQuery($dql)
    	->setParameter(1, $name)
    	->setParameter(2, $code)
    	->getResult();
    }
}